import fetch from '../utils/http'
import store from '../store'

export const loginCheck = (phone, password) => fetch('POST', `/api/user/login`, {
  phone: phone,
  password: password
})

/**
 * 获取个人信息接口
 * */
export const getMyPreofile = () => fetch('GET', `/person/${store.state.userInfo.userId}`)

/**
 * 获取当前登录用户的积分
 * */
export const getMyIntegral = () => fetch('GET', `/person/${store.state.userInfo.userId}/integral`)
/** */
export const forgetPassword = (phone, password, registerWay = 'WEBPAGE') => fetch('POST', `/user/forget`, {
  phone: phone,
  password: password,
  registerWay: registerWay
})
export const setClassInfo = (holeId = '', salesId = '', colorsId = '', num = '') => fetch('POST', `/api/classes/save_class_data`, {
  holeId: holeId,
  salesId: salesId,
  colorsId: colorsId,
  num: num
})
/**
 * 修改个人信息
 * */
export const editProfile = (datas) => fetch('POST', `/person/${store.state.userInfo.userId}/update`, datas)

export const commitPrice = (select, totalPrice) => fetch('POST', `/api/user/login`, {
  select: select,
  totalPrice: totalPrice
})
export const submitOrder = (name = '', phone = '', citys = '', cityDetails = '') => fetch('POST', `/api/class`, {
  name: name,
  phone: phone,
  citys: citys,
  cityDetails: cityDetails
})
